import 'package:flutter/material.dart';
import 'package:sports_new/utils/routes.dart';
import 'package:sports_new/widgets/share/share_sheet.dart';
import '../../resources/colours.dart';
import '../../utils/utils.dart';

class ShareButton extends StatelessWidget {
  const ShareButton({super.key,
    this.color = Colours.white,
    required this.route,
    this.title = '分享给你一个看比赛和数据的APP',
    this.content = '球客岛，专业体育比分预测平台',
    this.logoUrl,
    this.onTap,
    this.imageWidget,
    this.needChannel = false,
    this.icon = "icon_share.png",
  });

  final String icon;
  final Color color;
  final String route;
  final String title;
  final String content;
  final String? logoUrl;
  final bool needChannel;
  final Function<Widget>()? imageWidget;
  final Function()? onTap;

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () => Routes.toPage(Routes.share,
        arguments: ShareEntity(
          title: title,
          content: content,
          url: route,
          logo: logoUrl,
          needChannel: needChannel,
          imageWidget: imageWidget?.call(),
          onTap: onTap
        )
      ),
      child: SizedBox(
        width: 24,height: 40,
        child: Image.asset(
          Utils.getImgPath("icon_share.png"),
          color: color,
          width: 24
        )
      )
    );
  }
}
